const loadInfoLoader: import('webpack').LoaderDefinition = function (code) {
  this.cacheable(false)
  const injected = this._compiler?.$compluginInjected
  if (!injected) return

  const resource = this.resource
  const loadInfo = injected.loadMap.get(resource)

  if (!loadInfo || loadInfo[0] !== code) return
  const [, map, ast] = loadInfo

  this.callback(null, code, map!, ast ? { webpackAST: ast } : undefined)
}

export { loadInfoLoader as default }
